export const isTable = (node) => node.type === 'table';
/**
 * Converts "| table |" to "<table><tr><td>table</td></tr></table>"
 */
export const convertTable = (node) => {
    node.type = 'mdxJsxFlowElement';
    node.name = 'table';
    node.children = node.children.map((tableRow, i) => ({
        type: 'mdxJsxFlowElement',
        name: 'tr',
        attributes: [],
        children: tableRow.children.map((tableCell) => ({
            type: 'mdxJsxFlowElement',
            name: i === 0 ? 'th' : 'td',
            attributes: [],
            children: tableCell.children,
        })),
    }));
    const newChildren = [];
    if (node.children[0]) {
        newChildren.push({
            type: 'mdxJsxFlowElement',
            name: 'thead',
            attributes: [],
            children: [node.children[0]],
        });
    }
    if (node.children.length > 0) {
        newChildren.push({
            type: 'mdxJsxFlowElement',
            name: 'tbody',
            attributes: [],
            children: node.children.slice(1),
        });
    }
    node.children = newChildren;
};
